//
//  ChatFunctionPanel.m
//  TIMChat
//
//  Created by AlexiChen on 16/3/21.
//  Copyright © 2016年 AlexiChen. All rights reserved.
//

#import "ChatFunctionPanel.h"

@implementation ChatFunctionPanel

- (instancetype)init {
    if (self = [super init]) {
        _contentHeight = 105;
    }
    return self;
}

- (void)addOwnViews {
    _liveChat = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
    _liveChat.imageSize = CGSizeMake(60, 60);
    _liveChat.margin = UIEdgeInsetsMake(10, 0, 0, 10);
    _liveChat.titleLabel.textAlignment = NSTextAlignmentCenter;
    _liveChat.titleLabel.font = kAppMiddleTextFont;
    [_liveChat setTitleColor:kGrayColor forState:UIControlStateNormal];
    [_liveChat setTitle:ASLocalizedString(@"视频聊")forState:UIControlStateNormal];
    [_liveChat setImage:[UIImage imageNamed:@"im_video"] forState:UIControlStateNormal];
    [_liveChat addTarget:self action:@selector(onClickLiveChat:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_liveChat];
    if (!(IsCurrentUserMale)) _liveChat.hidden = YES;
    
    _sendGift = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
    _sendGift.imageSize = CGSizeMake(60, 60);
    _sendGift.margin = UIEdgeInsetsMake(10, 0, 0, 10);
    _sendGift.titleLabel.textAlignment = NSTextAlignmentCenter;
    _sendGift.titleLabel.font = kAppMiddleTextFont;
    [_sendGift setTitleColor:kGrayColor forState:UIControlStateNormal];
    [_sendGift setTitle:ASLocalizedString(@"送礼物")forState:UIControlStateNormal];
    [_sendGift setImage:[UIImage imageNamed:@"im_gift"] forState:UIControlStateNormal];
    [_sendGift addTarget:self action:@selector(onClickSendGift:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_sendGift];
    if (!(IsCurrentUserMale)) _sendGift.hidden = YES;
}

- (void)onClickLiveChat:(UIButton *)btn {
    if ([_chatDelegate respondsToSelector:@selector(onChatInputLiveChat)]) {
        [_chatDelegate performSelector:@selector(onChatInputLiveChat)];
    }
}

- (void)onClickSendGift:(UIButton *)btn {
    if ([_chatDelegate respondsToSelector:@selector(onChatInputSendGift)]) {
        [_chatDelegate performSelector:@selector(onChatInputSendGift)];
    }
}

- (void)relayoutFrameOfSubViews {
    [self alignSubviews:@[_liveChat, _sendGift] horizontallyWithPadding:0 margin:0 inRect:self.bounds];
}


#pragma mark - 垃圾桶
- (void)onClickImage:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputSendImage:)])
    {
        [_chatDelegate onChatInputSendImage:self];
    }
}

- (void)onClickPhoto:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputTakePhoto:)])
    {
        [_chatDelegate onChatInputTakePhoto:self];
    }
}

- (void)onClickFile:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputSendFile:)])
    {
        [_chatDelegate onChatInputSendFile:self];
    }
}

- (void)onClickVideo:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputRecordVideo:)])
    {
        [_chatDelegate onChatInputRecordVideo:self];
    }
}

@end
